<?php include('./templete/public/head.php')?>

<body class="bgcolor">

<div class="info-main">
    <!-- 全标已读   -->
    <div class="all-read">
        <a onclick="all_read()">全部标为已读</a>
    </div>
    <div class="info-content">

    </div>
</div>
</body>

</html>
<script>
    function get_comment() {
        $.ajax({
            url:'<?php echo url('get_message_list')?>',
            success:function (data) {
                $('.info-content').append(data);
            }
        })
    };
    get_comment();

    //获取更多评论
    $(function() {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function() {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if(load_flag){
                    load_flag=!load_flag;
                    $.ajax({
                        url: '<?php echo url('get_message_list')?>',
                        data:{
                            page:page,
                        },
                        success: function(data) {
                            if (data) {
                                $('.info-content').append(data);
                                load_flag=!load_flag;
                                page++;
                            }
                        }
                    })
                }
            }
        });
    });
    
    function all_read() {
        $.ajax({
            url:"<?php echo url('all_read')?>",
            success:function (data) {
                location.reload();
            }
        })
    }
</script>